package ca.llsutherland.squash.administrator;

import java.util.Calendar;

import ca.llsutherland.squash.domain.Administrator;
import ca.llsutherland.squash.domain.Clock;
import ca.llsutherland.squash.domain.Role;
import ca.llsutherland.squash.domain.helper.AdministratorsHelper;
import ca.llsutherland.squash.facade.FacadeFactory;
import ca.llsutherland.squash.role.RolesFixture;

public class AdministratorsFixture {

    public static Administrator createUnpersistedAdministrator(String firstname, String lastname, Clock dateCreated, Clock dateUpdated, String password) {
        return AdministratorsHelper.createUnpersistedAdministrator(firstname, lastname, dateCreated, dateUpdated, password);        
    }

    public static Administrator createUnpersistedAdministrator(String firstname, String lastname, Clock dateCreated, Clock dateUpdated, String password, Role role) {
        return AdministratorsHelper.createUnpersistedAdministrator(firstname, lastname, dateCreated, dateUpdated, password, role);
    }

    public static Administrator createNewAdministrator(String firstname, String lastname) {
        Role role = RolesFixture.findSuperAdministratorRole();
        int year = Calendar.getInstance().get(Calendar.YEAR);
        int month = Calendar.getInstance().get(Calendar.MONTH);
        int day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
        int hour = Calendar.getInstance().get(Calendar.HOUR);
        String password = "mypassword";
        Administrator administrator = createUnpersistedAdministrator(firstname, lastname, new Clock(year, month, day, hour, 0, 0), new Clock(year, month, day, hour, 0, 0), password, role);
        return FacadeFactory.getAdministrationFacade().createAdministrator(administrator);
    }

}
